//
//  BackupsSwitchView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/27.
//

import SwiftUI

//温馨提示弹窗
struct CommonBtnDialogView: View {
    let title :String
    let text :String
    let btn :String
    let alignment: TextAlignment
    let dismissCancel: () -> Void
    let dismiss: () -> Void

    var body: some View {
        PopupCenterView(title: title, dismiss: {
            dismissCancel()
        }) {
            ZStack {
                // 弹窗内容
                VStack(spacing: 20) {
                    Text(text)
                        .font(.system(size: 15))
                        .foregroundStyle(.bgNormalText2)
                        .multilineTextAlignment(alignment) // 设置文本对齐方式
                        .lineSpacing(4)//行间距
                        .tracking(2.5)//字符
                        .fixedSize(horizontal: false, vertical: true) // 允许垂直方向自适应大小
                        .frame(minHeight: 50)
                    HStack(spacing: 20) {
                        Text("取消")
                            .font(.system(size: 14))
                            .frame(maxWidth: .infinity)
                            .frame(height: 46)
                            .background(themeManager.themeColor.opacity(0.2))
                            .foregroundColor(themeManager.themeColor)
                            .cornerRadius(10)
                            .contentShape(Rectangle())
                            .onTapGesture {
                                dismissCancel()
                            }
                        
                        Text(btn)
                            .font(.system(size: 14))
                            .frame(maxWidth: .infinity)
                            .frame(height: 46)
                            .background(themeManager.themeColor)
                            .foregroundColor(.white)
                            .cornerRadius(10)
                            .contentShape(Rectangle())
                            .onTapGesture {
                                dismiss()
                            }
                    }
                }.padding(.horizontal, 10)
            }
        }
    }
}

//#Preview {
//    CommonBtnDialogView()
//}
//定义预览提供者
struct CommonBtnDIalogView_Previews: PreviewProvider {
    static var previews: some View {
        //使用预览共享配置
        configurePreviewEnvironment(for: CommonBtnDialogView(title: "测试", text: "问问我企鹅我企鹅完全恶趣味去",btn:"确定",alignment: .center) {} dismiss: { })
    }
}
